package com.wangxl.rabbitmqdemo.conf;

import com.wangxl.rabbitmqdemo.enumtype.RoutingKeyEnum;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: wangxl
 * @Date: 2019/3/23 10:50
 */
@Configuration(value = "simpleMQConfig")
public class SimpleMQConfig {

    /**
     * 声明一个简单的队列
     * @return
     */
    @Bean("simpleQueue")
    Queue getSimpleQueue(){
        return new Queue("simpleQueue",true);
    }

    /**
     * 声明一个directExchange
     * @return
     */
    @Bean("simpleExchange")
    DirectExchange getDirectExchange(){
        return new DirectExchange("simpleExchange");
    }

    /**
     * 声明一个Binding，绑定directExchange----------》simpleQueue
     * @return
     */
    @Bean("simpleBinding")
    Binding getSimpleBinding(){
        return new Binding("simpleQueue",Binding.DestinationType.QUEUE,"simpleExchange", RoutingKeyEnum.SIMPLE_KEY.getRoutingKey(),null);
    }


}
